package com.iv.durian.cloud.facade.support;

import com.iv.durian.cloud.Notify;
import com.iv.durian.cloud.facade.NotifyFacade;
import com.iv.durian.cloud.service.NotifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class NotifyFacadeImpl implements NotifyFacade {

    @Autowired
    private NotifyService notifyService;

    @Override
    public Notify get(@PathVariable(value = "notifyId") Integer notifyId) {
        return notifyService.get(notifyId, null);
    }

    @Override
    public void add(@RequestBody Notify notify) {
        notifyService.add(notify);
    }

    @Override
    public void update(@RequestBody Notify notify) {
        notifyService.update(notify);
    }

    @Override
    public int remove(@PathVariable(value = "notifyId") Integer notifyId) {
        return notifyService.remove(notifyId);
    }

    @Override
    public List<Notify> list(@RequestParam(value = "userId",required = false) Integer userId,
                             @RequestParam(value = "status",required = false) Integer status,
                             @RequestParam(value = "type",required = false) Integer type,
                             @RequestParam(value = "offset",required = false) Integer offset,
                             @RequestParam(value = "limit",required = false) Integer limit) {
        return notifyService.list(userId, status, type, offset, limit);
    }

    @Override
    public int count(@RequestBody Notify notify) {
        return notifyService.count(notify);
    }

}
